/**
 * @Copyright: Interactive Business Solution Pte Ltd, Singapore
 * @Author: Li Wen, 2007-11-22
 * @Version: 071122.001
 * Model class for itinerary, following properties are required
 * id, name, packageid, desp, breakfast, lunch, meal, offlineOperator
 */
package com.ibsol.model
{
	import com.ibsol.database.PhotoDAO;
	import com.ibsol.database.TourItemDAO;
	
	import mx.collections.ArrayCollection;
	
	[Bindable]
	[RemoteClass(alias="com.ibsol.tourix.model.Itinerary")]
	public class Itinerary
	{
		private var _id:int;
		private var _name:String;
		private var _packageid:int;
		private var _desp:String;
		private var _breakfast:String;
		private var _lunch:String;
		private var _meal:String;
		private var _offlineOperator:String;
		private var _updateTime:String;
		private var _sequence:int;
		private var _pairid:String;
		//Tour Item
		private var _tourItems:ArrayCollection = new ArrayCollection();
		private var tourItemLoaded:Boolean = false;
		//Photo 
		private var _photos:ArrayCollection = new ArrayCollection();
		private var photoLoaded:Boolean = false;
		/**
		 * Default constructor of Itinerary
		 */
		public function Itinerary()
		{
			_id = 0;
			_name = "";
			_packageid = 0;
			_desp = "";
			_breakfast = "";
			_lunch = "";
			_meal = "";
			_offlineOperator = "";
			_updateTime = "";
			_sequence = 0;
			_pairid="";
		}
		
		public function set id(value:int):void{
			this._id = value;
		}
		
		public function set name(value:String):void{
			this._name = value;
		}
		
		public function set packageid(value:int):void{
			this._packageid = value;
		}
		
		public function set desp(value:String):void{
			this._desp = value;
		}
		
		public function set breakfast(value:String):void{
			this._breakfast = value;
		}
		
		public function set lunch(value:String):void{
			this._lunch = value;
		}
		
		public function set meal(value:String):void{
			this._meal = value;
		}
		
		public function set offlineOperator(value:String):void{
			this._offlineOperator = value;
		}
		
		public function set updateTime(value:String):void{
			this._updateTime = value;
		}
		
		public function set sequence(value:int):void{
			this._sequence = value;
		}
		
		public function set pairid(value:String):void{
			this._pairid = value;
		}
		
		public function get pairid():String{
			return this._pairid;
		}
		
		public function get id():int{
			return this._id;
		}
		
		public function get name():String{
			return this._name;
		}
		
		public function get packageid():int{
			return this._packageid;
		}
		
		public function get desp():String{
			return this._desp;
		}
		
		public function get breakfast():String{
			return this._breakfast;
		}
		
		public function get lunch():String{
			return this._lunch;
		}
		
		public function get offlineOperator():String{
			return this._offlineOperator;
		}
		
		public function get updateTime():String{
			return this._updateTime;
		}
		
		public function get sequence():int{
			return this._sequence;
		}
		
		public function get meal():String{
			return this._meal;
		}
		/**
		 * Gets tourItems according to itinerary id
		 * @param:	null
		 * @return:	Array Collection of tour items
		 */
		public function get tourItems():ArrayCollection
		{
			if(!tourItemLoaded && id > 0)
			{
				var tourItemDAO:TourItemDAO = new TourItemDAO();
				tourItemDAO.loadTourItemsByItinerary(id,
					function(data:ArrayCollection):void
					{
						if(data)
							_tourItems = data;
					});
				tourItemLoaded = true;
			}
			return _tourItems;
		}
		/**
		 * Gets photos according to itineray id and type
		 * @param:	null
		 * @return:	Array Collection of photos
		 */
		public function get photos():ArrayCollection
		{
			if(!photoLoaded && id > 0)
			{
				var photoDAO:PhotoDAO = new PhotoDAO();
				photoDAO.loadPhotosByForeignData(id,"ITINERARY",
					function(data:ArrayCollection):void
					{
						if(data)
							_photos = data;
					});
				photoLoaded = true;
			}
			return _photos;
		}
	}
}